package com.pwc.conversionTool.entity;

import java.io.Serializable;
import java.util.Map;

import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Ignore;
import com.googlecode.objectify.annotation.Index;

@Entity
public class Operation implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7247208780721757445L;

	@Id
	private Long id;

	private String operationName;

	private String soapTemplate;

	private Key<SoapConnection> soapConnection;

	@Ignore
	private SoapConnection soapConnectionData;

	private Key<DataTemplate> dataAdaptor;

	@Ignore
	private DataTemplate dataAdaptorData;

	@Index
	private Key<Project> project;

	/**
	 * xpath is key, header[] is value
	 */
	private Map<String, String> mapping;

	public Operation(String operationName, String soapTemplate) {
		super();
		this.operationName = operationName;
		this.soapTemplate = soapTemplate;
	}

	public Operation(String operationName, String soapTemplate, Key<SoapConnection> soapConnection, Key<DataTemplate> dataAdaptor,
			Key<Project> project, Map<String, String> mapping) {
		super();
		this.operationName = operationName;
		this.soapTemplate = soapTemplate;
		this.soapConnection = soapConnection;
		this.dataAdaptor = dataAdaptor;
		this.project = project;
		this.mapping = mapping;
	}

	public Operation(Long id, String operationName, String soapTemplate, Key<SoapConnection> soapConnection, Key<DataTemplate> dataAdaptor,
			Key<Project> project, Map<String, String> mapping) {
		super();
		this.id = id;
		this.operationName = operationName;
		this.soapTemplate = soapTemplate;
		this.soapConnection = soapConnection;
		this.dataAdaptor = dataAdaptor;
		this.project = project;
		this.mapping = mapping;
	}

	public Operation() {
		super();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSoapTemplate() {
		return soapTemplate;
	}

	public void setSoapTemplate(String soapTemplate) {
		this.soapTemplate = soapTemplate;
	}

	@JsonIgnore
	public Key<SoapConnection> getSoapConnection() {
		return soapConnection;
	}

	public void setSoapConnection(Key<SoapConnection> soapConnection) {
		this.soapConnection = soapConnection;
	}

	@JsonIgnore
	public Key<DataTemplate> getDataAdaptor() {
		return dataAdaptor;
	}

	public void setDataAdaptor(Key<DataTemplate> dataAdaptor) {
		this.dataAdaptor = dataAdaptor;
	}

	@JsonIgnore
	public Key<Project> getProject() {
		return project;
	}

	public void setProject(Key<Project> project) {
		this.project = project;
	}

	public Map<String, String> getMapping() {
		return mapping;
	}

	public void setMapping(Map<String, String> mapping) {
		this.mapping = mapping;
	}

	public String getOperationName() {
		return operationName;
	}

	public void setOperationName(String operationName) {
		this.operationName = operationName;
	}

	public SoapConnection getSoapConnectionData() {
		return soapConnectionData;
	}

	public void setSoapConnectionData(SoapConnection soapConnectionData) {
		this.soapConnectionData = soapConnectionData;
	}

	public DataTemplate getDataAdaptorData() {
		return dataAdaptorData;
	}

	public void setDataAdaptorData(DataTemplate dataAdaptorData) {
		this.dataAdaptorData = dataAdaptorData;
	}

	@JsonIgnore
	@Transient
	public Key<Operation> getKey() {
		return Key.create(Operation.class, id);
	}

}
